﻿using System.Windows;
using System.Reflection;
using System.IO;
using System;
using Infrastructure.Diagnostics;
using PasswordControl.UI.WPF.Data;

namespace PasswordControl.UI.WPF
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        static App()
        {
            InitLog();
        }

        static void InitLog()
        {
            var appData = Configuration.AppDataDir;

            var logDir = Path.Combine(appData, "Logs");
            if (!Directory.Exists(logDir)) Directory.CreateDirectory(logDir);

            var logFile = string.Format("{0}.log", DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"));
            var logPath = Path.Combine(logDir, logFile);

            Logger.AddListener(new TextWriterLogListener(logPath));
        }
    }
}
